import random
import pygame

SCREEN_INFO = pygame.Rect(0,0,450,700)
FRAME_PRE_SEC = 60
LETTER_EVEN = pygame.USEREVENT
BG_PATH = './images/hats/'
KEY_LIST = ('q','w','e','r','t','y','u','i','o','p','a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m')
class GameScripte(pygame.sprite.Sprite) :
    def __init__(self, image_name, speed=1):
        super().__init__()
        self.image = pygame.image.load(image_name)
        self.rect = self.image.get_rect()
        self.speed = speed

    def update(self):
        self.rect.y += self.speed

class Backgroud(GameScripte):
    def __init__(self,second=False):
        super().__init__('./images/bj.jpg')
        if second :
            self.rect.y = -self.rect.height

    def update(self):
        super().update()
        if self.rect.y > SCREEN_INFO.height :
            self.rect.y = -self.rect.height


class Enemy(GameScripte) :
    def __init__(self):
            self.name = KEY_LIST[random.randint(0, 25)]
            self.image = f"{BG_PATH}{self.name}.png"
            super().__init__(self.image)
            self.speed = random.randint(1,3)
            self.rect.x = random.randint(1,SCREEN_INFO.width-self.rect.width)


    def update(self):
            super(Enemy, self).update()
            if self.rect.y >= SCREEN_INFO.height :
                self.kill()
